/*
* 封装路由模块
*/
// 引入 Vue
import Vue from 'vue'
// 引入VueRouter
import VueRouter from 'vue-router'
import Index from '../views/index.vue'
// 注册
Vue.use(VueRouter)
// 定义规则数组
const routes = [
  {
    path: '/',
    // 重定向到/index
    redirect: '/index'
  },
  // /index映射到Index组件
  // /table /代表根路径 加了直接写/table就能访问该路由
  {
    path: '/index',
    component: Index,
    children: [
      {
        path: 'table',
        component: () => import('../views/table.vue')
      },
      {
        path: 'tree',
        component: () => import('../views/tree.vue')
      }
    ]
  },
  {
    name: 'login',
    path: '/login',
    component: () => import('../views/login')
  }
]
// 创建路由对象
const router = new VueRouter({
  routes
})
// 暴露路由对象
export default router
